#ifndef __LOCK_GUARD_HPP__
#define __LOCK_GUARD_HPP__


//对锁进行封装


#include<pthread.h>
#include<iostream>
class LockGuard
{
public:
    LockGuard(pthread_mutex_t *mutex)
        :_mutex(mutex)
    {
        pthread_mutex_lock(_mutex);//加锁
    }
    ~LockGuard()
    {
        pthread_mutex_unlock(_mutex);
    }
private:
    pthread_mutex_t *_mutex;
};

#endif